//app.js
var {apikey} = require("./utils/config.js")
App({
  globalData:{
    currentCity:""
  },
  onLaunch(){
    wx.getLocation({
      type: 'wgs84',
      success:(res)=>{
        var {latitude,longitude} = res
        // console.log(latitude)
        // console.log(longitude);
        var url=`https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${apikey}&get_poi=1`
        wx.request({
          url,
          method: 'GET', 
          success:(res)=>{
            if(this.callback){
              // console.log("onLaunch")
              var city = res.data.result.address_component.city;
              wx.setStorageSync('locationCity', city)
              this.globalData.currentCity=city
              this.callback()
            }
          }
        })
      }
    })

   /*  setTimeout(()=>{
      console.log(this.callback)
      if(this.callback){
        console.log("onLaunch")
        this.callback()
      }
    },1000) */
  }
})